﻿/** 
	倒计时
 */
(function($){
$.fn.hrt=function(){
	var data="";
	var _DOM=null;
	var TIMER;
	createdom =function(dom){
		_DOM=dom;
		data=$(dom).attr("data");
		data = data.replace(/-/g,"/");
		data = Math.round((new Date(data)).getTime()/1000);
		$(_DOM).append("<ul class='hrt'><li class='hrtday'></li><li class='split'>天</li><li class='hrthour'></li><li class='split'>时</li><li class='hrtmin'></li><li class='split'>分</li><li class='hrtsec'></li><li class='split'>秒</li</ul>");
		reflash();

	};
	reflash=function(){
		var	range  	= data-Math.round((new Date()).getTime()/1000),
					secday = 86400, sechour = 3600,
					days 	= parseInt(range/secday),
					hours	= parseInt((range%secday)/sechour),
					min		= parseInt(((range%secday)%sechour)/60),
					sec		= ((range%secday)%sechour)%60;
		$(_DOM).find(".hrtday").html(nol(days));
		$(_DOM).find(".hrthour").html(nol(hours));
		$(_DOM).find(".hrtmin").html(nol(min));
		$(_DOM).find(".hrtsec").html(nol(sec));

	};
	TIMER = setInterval( reflash,1000 );
	nol = function(h){
		if(h<0){
			return 0;
		}else if(h<=9){
			return "0"+(h);
		}else{
			return (h);
		}
	};
	return this.each(function(){
		var $box = $(this);
		createdom($box);
	});
};
})(jQuery);
$(function(){
	$(".hrtbox").each(function(){
		$(this).hrt();
	});
	$("head").append("<style type='text/css'> " +
			".hrt {list-style:none; width:190px;margin:auto;padding:0 0 0 0;} " +
			".hrt li{float:left;background:#251C14 no-repeat;color:#fff;border-radius:50%;" +
			"padding:0 5px 0 5px;font-size:15px;font-weight:bold;margin-top:10px;} " +
			".hrt li.split{background:none;padding:0px 3px 0 3px;color:#000000;}" +
			"</style>");
});